﻿@{
    ViewBag.Title = "AddForm";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    layui.use(['jquery', 'form', 'laydate', 'common', 'optimizeSelectOption'], function () {
        var form = layui.form,
            $ = layui.$,
            laydate = layui.laydate,
            common = layui.common;
        var keyValue = $.request("keyValue");
        var id = $.request("id");
        var parentform = $.request("parentform");
        var currentWindow = !parent[parentform] ? common.currentWindow() : parent[parentform];
        //执行一个laydate实例
        laydate.render({
            elem: '#F_PlanTime'
            , btns: ['clear']
            , trigger: 'click',
            format: 'yyyy/MM/dd HH:mm:ss',
        });
        var materialId = $.request("materialId");
        $(function () {
            $("#F_MaterialId").bindSelect({
                url: "/MaterialManage/Material/GetListJson",
                id: "F_Id",
                text: "F_MaterialName"
            });
            $("#F_MaterialId").val(materialId);
            $("#F_PlanTime").val(keyValue);
            if (!!id) {
                common.ajax({
                    url: '/MaterialManage/OutStorage/GetFormJson',
                    dataType: 'json',
                    data: { keyValue: id },
                    async: false,
                    success: function (data) {
                        common.val('adminform', data);
                    }
                });
            }
            form.render();
        });
        wcLoading.close();
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var postData = data.field;
            common.submitForm({
                url: '/PlanManage/OutStoragePlan/SubmitForm?id='+id,
                param: postData,
                success: function () {
                    currentWindow.layui.table.reload('currentTableId', {}, true);
                }
            })
            return false;
        });
    });
    function searchOrder() {
        layui.use(['jquery', 'form', 'common'], function () {
            var $ = layui.$,
                common = layui.common;
            var parentform2 = window.name;
            common.modalOpen({
                title: "选择订单",
                url: "/MaterialManage/OutStorage/AddOrderForm?parentform=" + parentform2 + "&name=" + "F_OrderCode" + "&value=" + "F_OrderId" + "&ids=" + $('#F_OrderId').val(),
                width: "650px",
                height: "600px",
            });
        });
    }
</script>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <div class="layui-form layuimini-form" lay-filter="adminform">
                <div class="layui-form-item">
                    <label class="layui-form-label required">计划时间</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_PlanTime" name="F_PlanTime" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">订单</label>
                    <div class="layui-input-block">
                        <input id="F_OrderCode" name="F_OrderCode" lay-verify="required" type="text" maxlength="50" autocomplete="off" class="layui-input" onclick="searchOrder()" />
                        <input id="F_OrderId" name="F_OrderId" type="text" hidden />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">物料</label>
                    <div class="layui-input-block">
                        <select id="F_MaterialId" name="F_MaterialId" disabled>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">数量</label>
                    <div class="layui-input-block">
                        <input type="number" pattern="[0-9]*" id="F_Num" name="F_Num" lay-verify="required|number" oninput="if(value.length>8)value=value.slice(0,8)" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">车辆</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_CarNo" name="F_CarNo" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea id="F_Description" name="F_Description" class="layui-textarea" placeholder="请输入备注"></textarea>
                    </div>
                </div>
                <div class="layui-form-item text-right layui-hide">
                    <button class="layui-btn site-demo-active" lay-submit id="submit" lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</body>

